<?php
namespace Acme\Likipe\BlogBundle\Form;

use Doctrine\ORM\EntityRepository;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;

/*
 * Acme\Likipe\BlogBundle\Form\PostType
 */

class PostType extends AbstractType{
	public function buildForm( FormBuilder $builder, array $options ){
		$builder->add( 'author' );
		$builder->add( 'content' );
		
		$builder->add( 'category', 'entity', array(
				'class'	=> 'AcmeLikipeBlogBundle:Category',
				'multiple'	=> true,
				'property'	=> 'name',
				'query_builder'	=> function( EntityRepository $er ){
					return $er->createQueryBuilder( 'c' )
						->orderBy( 'c.id', 'ASC' );
				}
			));
	}
	
	public function getDefaultOptions( array $options )
	{
		return array(
				'data_class' => 'Acme\Likipe\BlogBundle\Entity\Post',
		);
	}
	
	public function getName()
	{
		return 'post';
	}
}
?>